package com.hxx.util;

import java.sql.*;

public class JDBCComon {
    private Connection con = null;
//    private Statement stm = null;
//    private ResultSet rs = null;
    public Connection getConnection() {
        try {
            Class.forName("com.mysql.jdbc.Driver");
            con = DriverManager.getConnection("jdbc:mysql://localhost:3306/auto_vote",
                    "root", "woshihu123");;
        } catch (ClassNotFoundException e) {
            e.printStackTrace();
        } catch (SQLException e) {
            e.printStackTrace();
        }
        return con;
    }

    public void closeDB(ResultSet rs,Statement st,Connection con){
        try{
            rs.close();
            st.close();
            con.close();
        }catch (SQLException e){
            e.printStackTrace();
        }

    }
}
